package com.admin.action.query_book_Info;

import com.admin.Action;
import com.admin.dto.QueryReturnListBean;
import com.admin.service.bookservice.BookServiceImpl;

import com.google.gson.Gson;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 *
 */

public class QueryAllBookAction extends Action {
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out=response.getWriter();
        HttpSession session = request.getSession();
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }

        String idCard = request.getParameter("card");
        System.out.println("7878787878"+idCard);
//        String borDate = request.getParameter("borTime");
//        String repayDate = request.getParameter("repaydate");
////        bordate,repaydate
//        borTime:borrowTime,returntime:returnTime


        List<QueryReturnListBean> list=null;

        BookServiceImpl booksService = new BookServiceImpl();

        list=booksService.QueryAllBookInfoByName(idCard);

        Gson gson = new Gson();

        String jsonStr = gson.toJson(list);

        System.out.println(jsonStr);

        out.print(jsonStr);


    }
}
